package gui

import (
	io_wails "clean/adapter/io/gui/wails"
	"clean/infra/config"
	"clean/usecase"
	"github.com/leaanthony/mewn"
	"github.com/wailsapp/wails"
)

type ServerWails struct {
	app usecase.Input
	gui *wails.App
}

func NewServerWails(cfg config.Config, app usecase.Input) *ServerWails {
	js := mewn.String("infra/io/gui/wails/build/main.js")
	css := mewn.String("infra/io/gui/wails/build/main.css")
	gui := wails.CreateApp(&wails.AppConfig{
		Width:  1024,
		Height: 768,
		Title:  "My Project",
		JS:     js,
		CSS:    css,
		Colour: "#131313",
	})
	s := &ServerWails{
		app: app,
		gui: gui,
	}

	h := io_wails.NewHandler(app)
	h.Init(gui)

	return s
}

func (s *ServerWails) Start() error {
	return s.gui.Run()
}
